<?php
session_start();
date_default_timezone_set("America/Sao_Paulo");
setlocale(LC_ALL, 'pt_BR');
//include "../../../../config/conexao.php";
include "../../../biblioteca/funcao.php";
extract($_GET);
?>
<html>
    
    <head>
        
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" type="text/css" href="../../../plugin/estilo.css">
        <link rel="stylesheet" type="text/css" href="../../../plugin/bootstrap/css/bootstrap-responsive.css">
        <link rel="stylesheet" type="text/css" href="../../../plugin/bootstrap/css/bootstrap.css"> 
        <script type="text/javascript" src="../../../plugin/jquery-1.7.2.js"></script>
        <script type="text/javascript" src="../../../plugin/bootstrap/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="../../../plugin/funcao.js" /></script>

        <title>Imprimir</title>
        <link href="../../../../base/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
            <!--[if lt IE 9]>
            <script src="plugin/html5.js"></script>
        <![endif]-->
</head>
    
    <body>
        
        
        <div style="padding: 20px;">
            
            <h4>Helpdesk :: Relat&oacute;rio :: Chamados abertos por Dia</h4>
            <br>
            <p class="pull-right"><a href="#" onClick="window.print();"><i class="icon-print"></i> Imprimir</a></p>
            <br>
            <table class="table table-striped table-bordered table-hover" >
              <tr>
                <td>&nbsp;</td>
                <td colspan="7"><div align="center">Pr&eacute;-Opera&ccedil;&atilde;o</div></td>
                <td colspan="11"><div align="center">Durante a Opera&ccedil;&atilde;o</div></td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td width="456"><big>&Aacute;REAS DE ATUA&Ccedil;&Atilde;O</big></td>
                <td width="20"><strong>28/10</strong></td>
                <td width="20"><strong>29/10</strong></td>
                <td width="20"><strong>30/10</strong></td>
                <td width="20"><strong>31/10</strong></td>
                <td width="20"><strong>01/11</strong></td>
                <td width="20"><strong>02/11</strong></td>
                <td width="20"><strong>03/11</strong></td>
                <td width="20"><strong>05/11</strong></td>
                <td width="20"><strong>06/11</strong></td>
                <td width="20"><strong>07/11</strong></td>
                <td width="20"><strong>08/11</strong></td>
                <td width="20"><strong>09/11</strong></td>
                <td width="20"><strong>12/11</strong></td>
                <td width="20"><strong>13/11</strong></td>
                <td width="20"><strong>14/11</strong></td>
                <td width="20"><strong>15/11</strong></td>
                <td width="20"><strong>16/11</strong></td>
                <td width="20"><strong>17/11</strong></td>
                <td width="148"><div align="center"><strong><big>Total</big></strong></div></td>
              </tr>
              <?php
              
                $sql = "SELECT * FROM setor ORDER BY set_nome";
                $res = sql($sql);
                $i = 0;
                while($linha = mysql_fetch_array($res)){ 
                    
                    // total
                    $sql_chamado = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' $onde";
                    $res_chamado = sql($sql_chamado);
                    $num_chamado = mysql_num_rows($res_chamado);
                    if ($i == 0){
                        $num_aux = $num_chamado;
                    } else {
                        $num_aux += $num_chamado;
                    }
                    
					
					  // aberto 28
                    $sql_chamado0 = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' AND cha_data='2013-10-28' $onde";
                    $res_chamado0 = sql($sql_chamado0);
                    $num_chamado0 = mysql_num_rows($res_chamado0);
                    if ($i == 0){
                        $num_aux_0 = $num_chamado0;
                    } else {
                        $num_aux_0 += $num_chamado0;
                    }
					
                    // aberto 29
                    $sql_chamado1 = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' AND cha_data='2013-10-29' $onde";
                    $res_chamado1 = sql($sql_chamado1);
                    $num_chamado1 = mysql_num_rows($res_chamado1);
                    if ($i == 0){
                        $num_aux_1 = $num_chamado1;
                    } else {
                        $num_aux_1 += $num_chamado1;
                    }
                    
                   // aberto 30
                    $sql_chamado2 = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' AND cha_data='2013-10-30' $onde";
                    $res_chamado2 = sql($sql_chamado2);
                    $num_chamado2 = mysql_num_rows($res_chamado2);
                    if ($i == 0){
                        $num_aux_2 = $num_chamado2;
                    } else {
                        $num_aux_2 += $num_chamado2;
                    }
                    
                    // aberto 31
                    $sql_chamado3 = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' AND cha_data='2013-10-31'  $onde";
                    $res_chamado3 = sql($sql_chamado3);
                    $num_chamado3 = mysql_num_rows($res_chamado3);
                    if ($i == 0){
                        $num_aux_3 = $num_chamado3;
                    } else {
                        $num_aux_3 += $num_chamado3;
                    }
                    
                    // aberto 01_11
                    $sql_chamado4 = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' AND cha_data='2013-11-01'  $onde";
                    $res_chamado4 = sql($sql_chamado4);
                    $num_chamado4 = mysql_num_rows($res_chamado4);
                    if ($i == 0){
                        $num_aux_4 = $num_chamado4;
                    } else {
                        $num_aux_4 += $num_chamado4;
                    }
					
					//
                    $sql_chamado5 = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' AND cha_data='2013-11-02'  $onde";
                    $res_chamado5 = sql($sql_chamado5);
                    $num_chamado5 = mysql_num_rows($res_chamado5);
                    if ($i == 0){
                        $num_aux_5 = $num_chamado5;
                    } else {
                        $num_aux_5 += $num_chamado5;
                    }
					
					// 
                    $sql_chamado6 = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' AND cha_data='2013-11-03'  $onde";
                    $res_chamado6 = sql($sql_chamado6);
                    $num_chamado6 = mysql_num_rows($res_chamado6);
                    if ($i == 0){
                        $num_aux_6 = $num_chamado6;
                    } else {
                        $num_aux_6 += $num_chamado6;
                    }
					
					// 
                    $sql_chamado7 = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' AND cha_data='2013-11-05'  $onde";
                    $res_chamado7 = sql($sql_chamado7);
                    $num_chamado7 = mysql_num_rows($res_chamado7);
                    if ($i == 0){
                        $num_aux_7 = $num_chamado7;
                    } else {
                        $num_aux_7 += $num_chamado7;
                    }
					
					// 
                    $sql_chamado8 = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' AND cha_data='2013-11-06'  $onde";
                    $res_chamado8 = sql($sql_chamado8);
                    $num_chamado8 = mysql_num_rows($res_chamado8);
                    if ($i == 0){
                        $num_aux_8 = $num_chamado8;
                    } else {
                        $num_aux_8 += $num_chamado8;
                    }
					
					// 
                    $sql_chamado9 = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' AND cha_data='2013-11-07'  $onde";
                    $res_chamado9 = sql($sql_chamado9);
                    $num_chamado9 = mysql_num_rows($res_chamado9);
                    if ($i == 0){
                        $num_aux_9 = $num_chamado9;
                    } else {
                        $num_aux_9 += $num_chamado9;
                    }

					// 
                    $sql_chamado10 = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' AND cha_data='2013-11-08'  $onde";
                    $res_chamado10 = sql($sql_chamado10);
                    $num_chamado10 = mysql_num_rows($res_chamado10);
                    if ($i == 0){
                        $num_aux_10 = $num_chamado10;
                    } else {
                        $num_aux_10 += $num_chamado10;
                    }

					// 
                    $sql_chamado11 = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' AND cha_data='2013-11-09'  $onde";
                    $res_chamado11 = sql($sql_chamado11);
                    $num_chamado11 = mysql_num_rows($res_chamado11);
                    if ($i == 0){
                        $num_aux_11 = $num_chamado11;
                    } else {
                        $num_aux_11 += $num_chamado11;
                    }

					// 
                    $sql_chamado12 = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' AND cha_data='2013-11-12'  $onde";
                    $res_chamado12 = sql($sql_chamado12);
                    $num_chamado12 = mysql_num_rows($res_chamado12);
                    if ($i == 0){
                        $num_aux_12 = $num_chamado12;
                    } else {
                        $num_aux_12 += $num_chamado12;
                    }

					// 
                    $sql_chamado13 = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' AND cha_data='2013-11-13'  $onde";
                    $res_chamado13 = sql($sql_chamado13);
                    $num_chamado13 = mysql_num_rows($res_chamado13);
                    if ($i == 0){
                        $num_aux_13 = $num_chamado13;
                    } else {
                        $num_aux_13 += $num_chamado13;
                    }

					// 
                    $sql_chamado14 = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' AND cha_data='2013-11-15'  $onde";
                    $res_chamado14 = sql($sql_chamado14);
                    $num_chamado14 = mysql_num_rows($res_chamado14);
                    if ($i == 0){
                        $num_aux_41 = $num_chamado14;
                    } else {
                        $num_aux_14 += $num_chamado14;
                    }    

					// 15 NOV
                    $sql_chamado15 = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' AND cha_data='2013-11-15'  $onde";
                    $res_chamado15 = sql($sql_chamado15);
                    $num_chamado15 = mysql_num_rows($res_chamado15);
                    if ($i == 0){
                        $num_aux_15 = $num_chamado15;
                    } else {
                        $num_aux_15 += $num_chamado15;
                    }
					
					// 16 NOV
                    $sql_chamado16 = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' AND cha_data='2013-11-16'  $onde";
                    $res_chamado16 = sql($sql_chamado16);
                    $num_chamado16 = mysql_num_rows($res_chamado16);
                    if ($i == 0){
                        $num_aux_16 = $num_chamado16;
                    } else {
                        $num_aux_16 += $num_chamado16;
                    }
					
					// 17 NOV
                    $sql_chamado17 = "SELECT * FROM chamado 
                    LEFT JOIN cha_status ON cha_status.cha_sta_id=chamado.cha_status
                    WHERE set_id='{$linha['set_id']}' AND cha_data='2013-11-17'  $onde";
                    $res_chamado17 = sql($sql_chamado17);
                    $num_chamado17 = mysql_num_rows($res_chamado17);
                    if ($i == 0){
                        $num_aux_17 = $num_chamado17;
                    } else {
                        $num_aux_17 += $num_chamado17;
                    }
              ?>
              <tr>
                <td><?=$linha['set_nome'];?></td>
                <td width="20"><?=$num_chamado0?></td>
                <td width="20"><?=$num_chamado1?></td>
                <td width="20"><?=$num_chamado2?></td>
                <td width="20"><?=$num_chamado3?></td>
                <td width="20"><?=$num_chamado4?></td>
                <td width="20"><?=$num_chamado5?></td>
                <td width="20"><?=$num_chamado6?></td>
                <td width="20"><?=$num_chamado7?></td>
                <td width="20"><?=$num_chamado8?></td>
                <td width="20"><?=$num_chamado9?></td>
                <td width="20"><?=$num_chamado10?></td>
                <td width="20"><?=$num_chamado11?></td>
                <td width="20"><?=$num_chamado12?></td>
                <td width="20"><?=$num_chamado13?></td>
                <td width="20"><?=$num_chamado14?></td>
                <td width="20"><?=$num_chamado15?></td>
                <td width="20"><?=$num_chamado16?></td>
                <td width="20"><?=$num_chamado17?></td>
                <td width="148"><div align="center">
                    <?=$num_chamado?>
                </div></td>
              </tr>
              <?php
                $i++;
                }
                ?>
              <tr>
                <th>Total</th>
                <th width="20"><big>
                  <?=$num_aux_0?>
                 </big></th>
                <th width="20"><big>
                  <?=$num_aux_1?>
                </big></th>
                <th width="20"><big>
                  <?=$num_aux_2?>
                </big></th>
                <th width="20"><big>
                  <?=$num_aux_3?>
                </big></th>
                <th width="20"><big>
                  <?=$num_aux_4?>
                </big></th>
                <th width="20"><big>
                  <?=$num_aux_5?>
                </big></th>
                <th width="20"><big>
                  <?=$num_aux_6?>
                </big></th>
                <th width="20"><big>
                  <?=$num_aux_7?>
                </big></th>
                <th width="20"><big>
                  <?=$num_aux_8?>
                </big></th>
                <th width="20"><big>
                  <?=$num_aux_9?>
                </big></th>
                <th width="20"><big>
                  <?=$num_aux_10?>
                </big></th>
                <th width="20"><big>
                  <?=$num_aux_11?>
                </big></th>
                <th width="20"><big>
                  <?=$num_aux_12?>
                </big></th>
                <th width="20"><big>
                  <?=$num_aux_13?>
                </big></th>
                <th width="20"><big>
                  <?=$num_aux_14?>
                </big></th>
                <th width="20"><big>
                  <?=$num_aux_15?>
                </big></th>
                <th width="20"><big>
                  <?=$num_aux_16?>
                </big></th>
                <th width="20"><big>
                  <?=$num_aux_17?>
                </big></th>
                <th width="148"><div align="center">
                    <?=$num_aux?>
                </div></th>
              </tr>
            </table>
    </div>
    </body>
    
</html>